/**
 * Carnegie Mellon University
 * School of Computer Science
 * MSIT eBusiness Technology
 * 
 * Team 8 - Infinity (2011 Spring)
 * infinity-team8@googlegroups.com
 * 
 * Professor: Jeffrey L. Eppinger
 * Program Faculty: Sujata Telang
 */

package formbean;

import java.util.ArrayList;
import java.util.List;

import org.mybeans.form.FormBean;

public class CustomerLoginForm extends FormBean {
	private String userName;
	private String password;
	private String button;
	
	public String getUserName()  { return userName; }
	public String getPassword()  { return password; }
	public String getButton()    { return button;   }
	
	public void setUserName(String s) { userName = s.trim();  }
	public void setPassword(String s) {	password = s.trim();  }
	public void setButton(String s)   { button = s.trim();    }
	
	public List<String> getValidationErrors() {
		List<String> errors = new ArrayList<String>();

		if (userName == null || userName.length() == 0) {
			errors.add("User Name is required");
		}
		
		if (userName.matches(".*[<>\"].*")) {
			errors.add("User Name may not contain angle brackets or quotes");
		}
		
		if (password == null || password.length() == 0) {
			errors.add("Password is required");
		}
		
		return errors;
	}
}